package course.ya.doc.from.code.model.lexer.project;

import java.util.Scanner;
import java.util.TreeMap;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.TreeMap;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.transform.TransformerException;

public class Test 
{
	public Test()
	{
		
	}
	public void TestTreeTwo()
	{
		
		try
		{
			 SyntaxTree st=new SyntaxTree();
			 FileReader reader = new FileReader("test.txt");
			 Scanner src=new Scanner(reader);
			 src.useDelimiter(";");
			 Scanner in=new Scanner(System.in);
			 int group=0;
			 int jump=0;
			 while(src.hasNext())
			 {
				 String str=src.next();
				 group=Integer.parseInt(in.next());
				 if(group==0)
				 {
					 st.insert(str, true,false);
				 }
				 else
				 {
					 st.insert(str, true,true);
				 }
				 jump=Integer.parseInt(in.next());
				 if(jump==0)
				 {
					 st.jumpUp();
				 }
				 
			 }
			 src.close();
			 in.close();
			 
		}
		catch(IOException e)
		{
			System.out.print(e.getLocalizedMessage());
		}
	}
	public void TestTree()
	{
		SyntaxTree st=new SyntaxTree();
		Scanner in=new Scanner(System.in);
		String data="";
		int group=0;
		boolean flag=false;
		
		for(int i=0;i<10;i++)
		{
			data=in.next();
			group=Integer.parseInt(in.next());
			if(group==0)
			{
				flag=false;
			}
			else
			{
				flag=true;
			}
			st.insert(data, flag, flag);
		}
		in.close();
	}
	public void myTest()
	{
		try
		{
			String[] Mas={
				"abstract",
				"assert",
				"boolean",
				"break",
				"byte",
				"case",
				"catch",
				"char",
				"class",
				"const",
				"continue",
				"default",
				"do",
				"double",
				"else",
				"enum",
				"extends",
				"final",
				"finally",
				"float",
				"for",
				"goto",
				"if",
				"implements",
				"import",
				"instanceof",
				"int",
				"interface",
				"long",
				"native",
				"new",
				"package",
				"private",
				"protected",
				"public",
				"return",
				"short",
				"static",
				"strictfp",
				"super",
				"switch",
				"synchronized",
				"this",
				"throw",
				"throws",
				"transient",
				"try",
				"void",
				"volatile",
				"while"
				};
		int[] mas1={0,0,0,0,0,1,1,0,1,0,0,0,1,0,1,1,0,0,0,0,1,0,1,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,1,0,0,1};
		XMLParser parser=new XMLParser("KeyWords.xml");
		parser.NewXMLKeyWords(Mas, mas1);
		TreeMap<String,Integer> map=new TreeMap<String, Integer>();
		map=parser.ReKeyWords("KeyWords.xml");
		System.out.println(map.keySet());			
		System.out.println(map.values());
		/*parser.WordConfigure("KeyWords.xml","assert", "primer", 2);
		map=parser.ReKeyWords("KeyWords.xml");
		System.out.println(map.keySet());			
		System.out.println(map.values());*/
		KeyWords kw=new KeyWords(parser);
		int k=kw.ValueKey("do");
		System.out.println(k);	
					
	}
	catch(ParserConfigurationException parsEx)
    {
        System.out.println(parsEx.getLocalizedMessage());
        parsEx.printStackTrace();
    }
	catch (TransformerException transformException)
    {
         System.out.println(transformException.getLocalizedMessage());
         transformException.printStackTrace();
    }
	catch (Exception e)
    {
            System.out.println(e.getLocalizedMessage());
            e.printStackTrace();
    }
	

}
}
